package com.changgou.goods.dao;


import com.changgou.goods.pojo.Brand;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * 映射dao方法
 * @Author: wzw
 * @Date: 2020/12/6 22:04
 * @version: 1.8
 */
public interface BrandMapper extends Mapper<Brand> {
    //todo 需要自己加
    //接口内部已经实现了方法

    /**
     * @author wzw
     * 查询分类对应的品牌集合
     * @Date 21:27 2020/12/10
     * @param categoryId
     * @return java.util.List<com.changgou.goods.pojo.Brand>
    **/
//    @Select("SELECT tb.* FROM tb_category_brand tcb,tb_brand tb WHERE tcb.category_id=#{categoryid} AND tb.id=tcb.brand_id") //老师的
    @Select("SELECT * FROM tb_brand where id in(select brand_id from tb_category_brand WHERE category_id = #{categoryId})") //自己写的
    List<Brand> findByCategory(Integer categoryId);
}
